<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta name="author" content="lcy">
    <script src="../jquery-3.1.1.js"></script>
    <title></title>
    <style>
        div{
            width: 400px;
            margin: 0 auto;
        }
        span{
            display: inline-block;
            height: 30px;
            line-height: 30px;
            text-align: center;
        }
        div span:nth-child(1){
            background-color: greenyellow;
            width: 100px;
        }
        div span:nth-child(2){
            background-color: lightgrey;
            width: 220px;
        }
        ul{
            margin: 0;
            padding: 0;
            list-style: none;
            border: 1px solid red;
            width: 218px;
            margin-left: 100px;
        }
        li{
            height: 50px;
            line-height: 50px;
            text-align: center;
            border-bottom: 1px dotted darkred;
        }
        .no{
            display: none;
        }
        li:hover{
            background-color: #999;
        }
    </style>
</head>
<body>
    <div>
        <span>选择项目:</span><span>未选择</span>
        <ul class="no">
            <li>html5</li>
            <li>css</li>
            <li>js</li>
            <li>jquery</li>
        </ul>
    </div>
    
</body>
</html>
<script>
    $('div span:nth-child(2)').click(function(){
        $('ul').toggleClass('no');
    })
    $('li').click(function(){
        $('ul').addClass('no');
        var re=$(this).html();
        $('div span:nth-child(2)').html(re);
    })
</script>